package ml.uuku.swipeheadertabs.ui.fragment;

import ml.uuku.swipeheadertabs.adapter.ViewPagerFragmentAdapter;
import ml.uuku.swipeheadertabs.ui.fragment.base.BaseViewPagerFragment;

/**
 * 作为一个示例，用来展示书名的列表
 * 
 * @author <a href=http://my.oschina.net/uuku>uuku</a>
 * @version V0.1
 */
public class BooksListFragment extends BaseViewPagerFragment {

    private ViewPagerFragmentAdapter mAdapter;

    @Override
    protected void setPagerAdapter(ViewPagerFragmentAdapter pagerAdapter) {
        mAdapter = pagerAdapter;
        mAdapter.addFragment(new SimpleStringListFragment(), "程序设计");
        mAdapter.addFragment(new SimpleStringListFragment(), "数据结构");
        mAdapter.addFragment(new SimpleStringListFragment(), "操作系统");
        mViewPager.setOffscreenPageLimit(3);
    }

    public void setSwipeRefreshEnable(boolean enable) {
        SimpleStringListFragment fragment = (SimpleStringListFragment) mAdapter.getItem(mViewPager.getCurrentItem());
        fragment.setSwipeRefreshEnable(enable);
    }
}
